<template>
	<view class="page-list">
		<view class="list" v-for="(item, index) in list" :key="index">
			<view class="item" @click="routerPage(item, '/pages/project/project')">{{ item.title }}</view>
		</view>
	</view>
</template>

<script setup>
import { onMounted, ref } from 'vue'
import { request } from '@/utils/request.js';  
import { onLoad } from '@dcloudio/uni-app';

const props = defineProps({
	htmlNodes: {
		type: String,
		default: ""
	}
})

let list = ref([])

// 触底刷新
const scrolltolower = () => {
	// for (let i = 0; i < 30; i++) {
	//   indexList.value.push({
	//   });
	// }
}

const getListData = (type) => {
	let tUrl = ""
	switch(type){
		case 'project':
			tUrl = "sys_bus_project_list";
			break;
		case 'introduce':
			tUrl = "sys_master_data_list";
			break;
		case 'example':
			tUrl = "sys_case_list";
			break;
	}
	
	request({
		url: `/system/dict/data/type/${tUrl}`,
		data: {},
	}).then(res => {
		const data = res.data.map(item => {
			return {
				id: item.dictCode,
				title: item.dictLabel
			}
		})
		list.value = [...data]
	})
}

const routerPage = (item, path) => {
	uni.navigateTo({
		url: `${path}?id=${item.id}`
	})
}

onLoad((opt) => {
	uni.setNavigationBarTitle({
		title: opt.title
	});
	getListData(opt.type)
})

</script>

<style lang="scss" scoped> 
.page-list{
	color: $uni-text-color-yellow;
	min-height: 100vh;
	padding: 20rpx;
	
	> .list {
		> .item{
			padding: 20rpx;
		}
	}
	
	> .list:not(:last-child){
		border-bottom: 1rpx solid $uni-bg-color-mask;
	}
}
</style>
